<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-10-23 10:04:24
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 生产车间
 */

namespace App\Models;
 
class ProDept extends BaseModel
    {
    public $timestamps = true;
    public $table = "basedata_pro_dept";
    protected $guarded = [];
    protected $casts = [];

    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'table_status');
            });
        }

    public function department()
        {
        return $this->belongsTo(Department::class);
        }
    public function process()
        {
        return $this->hasManyThrough(ProProcesses::class, ProProcessDept::class, "pro_dept_id", "id", "id", "process_id");
        }
    public function process_dept()
        {
        return $this->hasMany(ProProcessDept::class, "pro_dept_id");
        }
    }
